package com.itheima.controller.clazzInfo;

import com.itheima.domin.pojo.Clazz;
import com.itheima.domin.pojo.Log;
import com.itheima.domin.query.ClazzQuery;
import com.itheima.domin.vo.Result;
import com.itheima.service.ClazzService;
import com.itheima.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**班级控制
 * @Author:上官徵羽
 * @Date: 2025/07/11 17:47
 * @Description TODO 今日内容:
 */
@RestController
@Slf4j
@RequestMapping(value = "/clazzs")
public class ClazzController {
    @Autowired
    private ClazzService clazzService;


    /** 班级列表分页查询 */
    @GetMapping
    public Result findAll(ClazzQuery clazzQuery){
        log.info("ClazzController findAll");

        return Result.success(clazzService.findAll(clazzQuery));
    }

    /** 班级数据回显 */
    @GetMapping("/{id}")
    public Result selectClazzId(@PathVariable("id") Integer id){
        return Result.success(clazzService.selectClazzId(id));

    }

    /** 修改班级 */
    @PutMapping
    public Result updateClazzId(@RequestBody Clazz clazz){
        clazzService.updateClazzId(clazz);
        return Result.success();
    }

    /** 删除班级 */
    @DeleteMapping("/{id}")
    public Result deleteClazzIds(@PathVariable("id") Integer id){
        clazzService.deleteClazzIds(id);
        return Result.success();
    }

    /**
     * 添加班级
     * @param clazz
     * @return
     */
    @PostMapping
    public Result addClazzAndMaster(@RequestBody Clazz clazz){
        clazzService.addClazzAndMaster(clazz);
        return Result.success();
    }

    /**
     * 查询全部班级
     * @return
     */
    @GetMapping("/list")
    public Result select(){
        return Result.success(clazzService.select());
    }
}
